import java.math.BigInteger;

public class Problem16 {

    public static void main(String[] args) {
	BigInteger sum = BigInteger.valueOf(2).pow(1000);
	int allSum = 0;
	String strin = new String();
	strin = String.valueOf(sum);
	char[] ch = new char[30000];
	strin.getChars(0, strin.length(), ch, 0);
	System.out.println(ch);
	for (int i = 0; i < ch.length; i++) {
	    if ((Character.getNumericValue(ch[i])) == -1) {
		break;
	    } else
		allSum = allSum + Character.getNumericValue(ch[i]);

	}
	System.out.println(allSum);
    }

}
